home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: May, 1997
- // Author: Carol Levy
- //
- // Description:
- // dynExecuteFieldCommands executes the field command and
- // ConnectDynamic commands.
- //
- // Input Arguments():
- // int $isCreate -- create or add mode
- // string $fieldCmd -- the field command string (except for the selection)
- //
- // Return Value:
- // None.
- //
-
- //
- // ============== dynExecuteFieldCommands ==============
- //
- // SYNOPSIS
- // Execute the field command and connectDynamic command.
- // If executing a "Create"/positional field command, all items in
- // the selection list will be connected to the field, to be
- // influenced by it.
- // If executing an "Add" field command, add the field to all
- // items in the selection list.
- //
- global proc dynExecuteFieldCommands(int $isCreate, string $fieldCmd)
- {
- string $selected[] = `ls -sl`;
-
- if (!$isCreate && size($selected) == 0)
- {
- warning "Nothing is selected to add a field to.";
- return;
- }
-
- // filter out the names of any selected auxiliaries,
- // because we do not want to connect a field to another field.
- // The node name dynBase takes in fields, emitters, and collisions.
- //
- string $selectedAux[] = `ls -sl -type dynBase`;
- int $ii;
- for ($ii = 0; $ii < size($selected); $ii++)
- {
- // search for the name of this selected item
- // among the selected fields. If we find it there,
- // erase this item from the array.
- //
- int $jj;
- for ($jj = 0; $jj < size($selectedAux); $jj++)
- {
- if ($selected[$ii] == $selectedAux[$jj])
- {
- $selected[$ii] = "";
- break;
- }
- }
- }
-
- // Execute the field command.
- //
- string $fieldNames[] = evalEcho ($fieldCmd);
-
- // If creating a positional field, and there are objects selected,
- // connect them to the new field.
- //
- if ($isCreate && size($selected) > 0)
- {
- string $connectNames = "";
- for ($i = 0; $i < size($selected); $i++)
- {
- string $objName = $selected[$i];
- if (size($objName)>0)
- $connectNames = $connectNames + " " + $objName;
- }
- if (size($connectNames) > 0)
- {
- string $connectCmd =
- "connectDynamic -f " + $fieldNames[0] + " " + $connectNames;
- evalEcho($connectCmd);
- }
- }
- }
-